package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.RecruitCvMapper;
import com.ruoyi.system.domain.RecruitCv;
import com.ruoyi.system.service.IRecruitCvService;

/**
 * 简历筛选Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-14
 */
@Service
public class RecruitCvServiceImpl implements IRecruitCvService 
{
    @Autowired
    private RecruitCvMapper recruitCvMapper;

    /**
     * 查询简历筛选
     * 
     * @param id 简历筛选主键
     * @return 简历筛选
     */
    @Override
    public RecruitCv selectRecruitCvById(Long id)
    {
        return recruitCvMapper.selectRecruitCvById(id);
    }

    /**
     * 查询简历筛选列表
     * 
     * @param recruitCv 简历筛选
     * @return 简历筛选
     */
    @Override
    public List<RecruitCv> selectRecruitCvList(RecruitCv recruitCv)
    {

        if(recruitCv == null){
            recruitCv = new RecruitCv();
        }
        if(SecurityUtils.hasRole("travel") && !SecurityUtils.hasRole("admin")){
            recruitCv.setUserId(SecurityUtils.getUserId());
            return recruitCvMapper.selectRecruitCvList(recruitCv);
        }



        return recruitCvMapper.selectRecruitCvList(recruitCv);

    }

    /**
     * 新增简历筛选
     * 
     * @param recruitCv 简历筛选
     * @return 结果
     */
    @Override
    public int insertRecruitCv(RecruitCv recruitCv)
    {
        recruitCv.setCreateTime(DateUtils.getNowDate());
        recruitCv.setUserId(SecurityUtils.getUserId());
        recruitCv.setProgress("1");
        return recruitCvMapper.insertRecruitCv(recruitCv);
    }

    /**
     * 修改简历筛选
     * 
     * @param recruitCv 简历筛选
     * @return 结果
     */
    @Override
    public int updateRecruitCv(RecruitCv recruitCv)
    {
        recruitCv.setUpdateTime(DateUtils.getNowDate());
        return recruitCvMapper.updateRecruitCv(recruitCv);
    }

    /**
     * 批量删除简历筛选
     * 
     * @param ids 需要删除的简历筛选主键
     * @return 结果
     */
    @Override
    public int deleteRecruitCvByIds(Long[] ids)
    {
        return recruitCvMapper.deleteRecruitCvByIds(ids);
    }

    /**
     * 删除简历筛选信息
     * 
     * @param id 简历筛选主键
     * @return 结果
     */
    @Override
    public int deleteRecruitCvById(Long id)
    {
        return recruitCvMapper.deleteRecruitCvById(id);
    }
}
